<?php
/*
	个人中心
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();

if($_RQ['op']=='main'){
	$mid=intval($_RQ['mid']);
	if(!$mid){
		$mid=$_SESSION['uid'];
	}
	$item=$this->get('card',array('mid'=>$mid));
	if(!$item){
		//没有名片信息，直接跳转名片编辑页
		exi('','','/info/');
	}
	$item['avatar']=$item['avatar']?tomedia($item['avatar']):$this->plugin_resource.'images/header.png';
	$item['bgimg']=$item['bgimg']?tomedia($item['bgimg']):$this->plugin_resource.'images/bgimg/bg1.jpg';
	$return['member_secret']=$this->get('member_secret',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$item['mid']));
	if($item['mid']==$_SESSION['uid']){
		$return['owner']=true;
	}else{
		//检查本人是否已有微名片
		$check=$this->get('card',array('mid'=>$_SESSION['uid']),array('id'));
		if($check){
			$return['have']=true;
		}else{
			$return['no']=true;
		}
		$collect=$this->getcolumn('collect',array('mid'=>$_SESSION['uid'],'collect_mid'=>$mid),'id');
		$collected=$this->getcolumn('collect',array('mid'=>$mid,'collect_mid'=>$_SESSION['uid']),'id');
		if($collect && $collected){
			$collect_each=true;
		}
		$return['member_secret']['paymobile']=1;
		if($return['member_secret']['mobile_fee']>0){
			$return['member_secret']['paymobile']=$this->getcolumn('feelog',array('name'=>'mobile_fee','ispay'=>1,'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'tomid'=>$item['mid']),'ispay');
		}
		$return['member_secret']['payemail']=1;
		if($return['member_secret']['email_fee']>0){
			$return['member_secret']['payemail']=$this->getcolumn('feelog',array('name'=>'email_fee','ispay'=>1,'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'tomid'=>$item['mid']),'ispay');
		}
		$return['member_secret']['payaddress']=1;
		if($return['member_secret']['address_fee']>0){
			$return['member_secret']['payaddress']=$this->getcolumn('feelog',array('name'=>'address_fee','ispay'=>1,'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'tomid'=>$item['mid']),'ispay');
		}
		$return['member_secret']['paywechat']=1;
		if($return['member_secret']['wechat_fee']>0){
			$return['member_secret']['paywechat']=$this->getcolumn('feelog',array('name'=>'wechat_fee','ispay'=>1,'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'tomid'=>$item['mid']),'ispay');
		}
		$return['member_secret']['payqq']=1;
		if($return['member_secret']['qq_fee']>0){
			$return['member_secret']['payqq']=$this->getcolumn('feelog',array('name'=>'qq_fee','ispay'=>1,'uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'tomid'=>$item['mid']),'ispay');
		}
	}
	$return['zan']=$this->count('like',array('like_mid'=>$item['mid']));
	$return['renmai']=$this->count('collect',array('collect_mid'=>$item['mid']));
	$return['look']=$this->count('look',array('look_mid'=>$item['mid']));
	$return['item']=$item;
	$setting=$this->get('member_secret',array('mid'=>$mid));
	foreach($setting as &$value){
		if($return['owner']){
			$value=true;
		}else{
			if($collect_each && $value==1){
				$value=true;
			}
			if($value==2){
				$value=true;
			}
			if(!$value){
				$value=true;
			}
		}
	}
	$return['setting']=$setting;
	exi($return);
}